package com.kkd.kkdapp.fragment;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.kkd.kkdapp.R;
import com.kkd.kkdapp.activity.KKDWebActivity;
import com.kkd.kkdapp.activity.LoginActivity;
import com.kkd.kkdapp.adapter.FindOtherListAdapter;
import com.kkd.kkdapp.db.CurUserModel;
import com.kkd.kkdapp.http.entity.AssesData;
import com.kkd.kkdapp.http.entity.FindData;
import com.kkd.kkdapp.http.entity.HomeRecommend;
import com.kkd.kkdapp.http.entity.LendData;
import com.kkd.kkdapp.http.manager.HttpCallBack;
import com.kkd.kkdapp.http.manager.KkdHttpMagager;
import com.kkd.kkdapp.listener.OnSingleClickListener;
import com.kkd.kkdapp.utils.AppUtil;
import com.kkd.kkdapp.utils.DialogUtils;
import com.kkd.kkdapp.utils.PreferenceUtils;
import com.kkd.kkdapp.utils.SystemUtils;
import com.kkd.kkdapp.utils.Time_Date;
import com.kkd.kkdapp.view.KKDHorizontalScrollView;
import com.kkd.kkdapp.view.KkdListHeader;
import com.kkd.kkdapp.view.ScrollerLayout;
import com.kkd.kkdapp.view.ScrollerLayout.OnPullListener;
import com.kkd.kkdapp.view.ScrollerLayout.ScrollStateProvider;
import com.kkd.kkdapp.view.banner.CycleBannerView;
import com.kkd.kkdapp.view.banner.listener.OnBannerClickListener;
import com.kkd.kkdapp.view.banner.loader.KBannerImagLoader;
import com.kkd.kkdapp.view.xlistview.XListViewHeader;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

public class FindFragment extends Fragment implements OnClickListener {
	private Activity mCurActivity;
	private static final int SUCCESS_REQUEST = 0;
	private static final int FAIL_REQUEST = 1;
	private static final int END_REFRESH = 2;
	private static final int SUCCESS_REQUEST_COUNT = 3;
	private TextView tv_title_shop;
	// private TextView tv_summary_shop;
	private View mContentView;
	private CycleBannerView mCycleBannerView;
	private View linear_anquan;
	private View linear_help;
	private View rel_toShop;
	private TextView tv_num_more_find_tree;
	private ImageView happy_new;
	private Intent intent;
	private ScrollerLayout find_sl;
	private ScrollView mScrollView;
	private KkdListHeader mHeaderView;
	private RelativeLayout mHeaderViewContent;
	// private TextView mHeaderTimeView;
	private android.widget.LinearLayout.LayoutParams params_first;
	private android.widget.LinearLayout.LayoutParams params;
	private ArrayList<HomeRecommend> list_active = new ArrayList<HomeRecommend>();
	private DisplayImageOptions options;
	private String securityUrl = "";// 安全保障url
	private String beginnerGuideUrl = "";// 新手指南url
	private String happyShopUrl = "";// 快乐币商店url
	private String lendUrl = "";// lendUrl
	private String moneyTreeUrl = "";// 摇钱树url
	private String inviteStrategyUrl = "";// 邀请攻略url
	private String assesUrl = "";// 风险评估url
	private String lendTitle;
	private FindData data;
	private ImageView icon_anquan;
	private ImageView icon_xinshouhelp;
	private ImageView icon_happyshop;
	private ListView mListView;
	private View call_toService;
	private Dialog dialog_service;
	private String coinMisUrl; // 快乐币任务url
	private List<LendData> otherList = new ArrayList<LendData>();
	private FindOtherListAdapter findOtherListAdapter;
	private Handler mHandler = new Handler() {

		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case SUCCESS_REQUEST:
				FindData data = (FindData) msg.obj;
				PreferenceUtils.getInstance().setFindData(mCurActivity, data);
				// 设置水平滚动图片

				if (data.getActivities() != null
						&& data.getActivities().size() > 0) {
					Gson gson = new Gson();
					String json1 = gson.toJson(list_active);
					String json2 = gson.toJson(data.getActivities());
					if (!json1.endsWith(json2)) {
						list_active.clear();
						list_active.addAll(data.getActivities());
						// mCycleBannerView.notifyDataSetChanged();
						mCycleBannerView.update(list_active);
					}
					mCycleBannerView.setVisibility(View.VISIBLE);
					iv_default_banner.setVisibility(View.GONE);
				} else {
					mCycleBannerView.setVisibility(View.GONE);
					iv_default_banner.setVisibility(View.VISIBLE);
				}
				// 设置安全保障url
				securityUrl = data.getSecurityUrl();
				// 设置新手指南url
				beginnerGuideUrl = data.getBeginnerGuideUrl();
				// 设置新手攻略url
				inviteStrategyUrl = data.getInviteStrategyUrl();
				/*
				 * 设置快乐币商店
				 */
				if (data.getHappyShop().getHappyShopFlag() == 1) {
					rel_toShop.setVisibility(View.VISIBLE);
					happyShopUrl = data.getHappyShop().getHappyShopUrl();
					tv_title_shop.setText(data.getHappyShop()
							.getHappyShopTitle());

					ImageLoader.getInstance().displayImage(
							data.getHappyShop().getHappyShopImageUrl(),
							icon_happyshop, R.drawable.find_toshop_new);

					// tv_summary_shop.setText(data.getHappyShop()
					// .getHappyShopDesc());
				} else {
					rel_toShop.setVisibility(View.GONE);
				}
				if (!TextUtils.isEmpty(data.getHappyShop()
						.getHappyShopNewImageUrl())) {

					if (data.getHappyShop().getNewImageTimestmp() > PreferenceUtils
							.getInstance().getTimeStamp(mCurActivity)) {
						happy_new.setVisibility(View.VISIBLE);
						ImageLoader.getInstance().displayImage(
								data.getHappyShop().getHappyShopNewImageUrl(),
								happy_new);
					} else {
						happy_new.setVisibility(View.INVISIBLE);
					}
				}
				// 设置安全保障和新手指南的图标

				ImageLoader.getInstance().displayImage(
						data.getSecurityImageUrl(), icon_anquan,
						R.drawable.find_protect_only);
				ImageLoader.getInstance().displayImage(
						data.getBeginnerGuideImageUrl(), icon_xinshouhelp,
						R.drawable.find_help_only);

				// 快乐币任务url
				coinMisUrl = data.getHappyShop().getCoinMisUrl();
				/*
				 * 设置otherList的条目
				 */
				if (data.getOtherList() != null
						&& data.getOtherList().size() > 0) {
					otherList.clear();
					otherList.addAll(data.getOtherList());
					findOtherListAdapter.notifyDataSetChanged();
				}
				/*
				 * 设置风险评估条目
				 */
				AssesData assesData = data.getAsses();
				if (assesData != null
						&& !TextUtils.isEmpty(assesData.getAssesTitle())
						&& !TextUtils.isEmpty(assesData.getAssesUrl())) {
					toTiskTest.setVisibility(View.VISIBLE);
					ImageLoader.getInstance().displayImage(
							assesData.getAssesImageUrl(), iv_riskTest,
							R.drawable.icon_risk_find);
					tv_title_asses.setText(assesData.getAssesTitle());
					tv_desc_asses.setText(assesData.getAssesDesc());
					assesUrl = assesData.getAssesUrl();
				} else {
					toTiskTest.setVisibility(View.GONE);
				}
				break;
			case FAIL_REQUEST:
				// 加载缓存的banner
				loadBannerCache();
				String desc = (String) msg.obj;
				AppUtil.makeToastForCustomer(mCurActivity, desc);
				break;
			case END_REFRESH:
				Time_Date time_Date = new Time_Date();
				String time = time_Date.get_Year_Day();
				// mHeaderTimeView.setText(time);
				mHeaderView.setState(XListViewHeader.STATE_NORMAL);
				mHeaderView.setVisibility(View.GONE);
				find_sl.clearState();
				break;
			case SUCCESS_REQUEST_COUNT:
				break;
			default:
				break;
			}
		}
	};
	private ImageView iv_default_banner;
	private View toTiskTest;
	private ImageView iv_riskTest;
	private TextView tv_title_asses;
	private TextView tv_desc_asses;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mContentView = inflater.inflate(R.layout.fragment_find, container,
				false);
		initView();
		setListener();
		return mContentView;
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		mCurActivity = activity;
	}

	private void initView() {
		/*
		 * 下拉刷新
		 */
		find_sl = (ScrollerLayout) mContentView.findViewById(R.id.find_sl);
		mHeaderView = new KkdListHeader(mCurActivity);
		// mHeaderView.setY(SystemUtil.dip2px(mContext, 60));
		mHeaderViewContent = (RelativeLayout) mHeaderView
				.findViewById(R.id.xlistview_header_content);
		find_sl.addTopView(mHeaderView);
		iv_default_banner = (ImageView) mContentView
				.findViewById(R.id.iv_default_banner);
		LayoutParams params_iv_default_banner = iv_default_banner
				.getLayoutParams();
		params_iv_default_banner.width = LayoutParams.MATCH_PARENT;
		params_iv_default_banner.height = (int) (SystemUtils
				.getScreenWidth(mCurActivity) * (436f / 750f));
		iv_default_banner.setLayoutParams(params_iv_default_banner);

		mCycleBannerView = (CycleBannerView) mContentView
				.findViewById(R.id.cycle_banner_view);
		LayoutParams layoutParams = mCycleBannerView.getLayoutParams();
		layoutParams.width = LayoutParams.MATCH_PARENT;
		layoutParams.height = (int) (SystemUtils.getScreenWidth(mCurActivity) * (436f / 750f));
		mCycleBannerView.setLayoutParams(layoutParams);
		mCycleBannerView.setImages(list_active)
				.setImageLoader(new KBannerImagLoader())
				.setOnBannerClickListener(new OnBannerClickListener() {

					@Override
					public void OnBannerClick(int position) {
						try {
							String url = list_active.get(position).getUrl();
							if (!TextUtils.isEmpty(url)) {
								SystemUtils.onEvent("Regular_Banner_"
										+ (position + 1), 1);
								Intent intent = new Intent(mCurActivity,
										KKDWebActivity.class);
								intent.putExtra("url", url);
								intent.putExtra("shareUrl",
										list_active.get(position).getShareUrl());
								startActivity(intent);
							}
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				}).start();
		// mCycleBannerView.setImgSources(list_active);
		/*
		 * 此处为设置2张默认bannner
		 */
		HomeRecommend homeRecommend1 = new HomeRecommend();
		homeRecommend1.setImage("");
		homeRecommend1.setTitle("");
		homeRecommend1.setUrl("");
		homeRecommend1.setDesc("");
		homeRecommend1.setShareUrl("");
		HomeRecommend homeRecommend2 = new HomeRecommend();
		homeRecommend2.setImage("");
		homeRecommend2.setTitle("");
		homeRecommend2.setUrl("");
		homeRecommend2.setDesc("");
		homeRecommend2.setShareUrl("");
		list_active.add(homeRecommend1);
		list_active.add(homeRecommend2);
		// mCycleBannerView.notifyDataSetChanged();
		mCycleBannerView.update(list_active);
		// 安全保障
		linear_anquan = mContentView.findViewById(R.id.linear_anquan);
		mScrollView = (ScrollView) mContentView
				.findViewById(R.id.scroll_vertical);
		// 新手指南
		linear_help = mContentView.findViewById(R.id.linear_help);
		// 快乐商城
		rel_toShop = mContentView.findViewById(R.id.rel_toShop);
		// 快乐商城标题
		tv_title_shop = (TextView) mContentView
				.findViewById(R.id.tv_title_shop);
		// 快乐商城副标题
		// tv_summary_shop = (TextView) mContentView
		// .findViewById(R.id.tv_summary_shop);
		happy_new = (ImageView) mContentView.findViewById(R.id.happy_new);
		// 水平滚动图片参数
		params_first = new android.widget.LinearLayout.LayoutParams(
				SystemUtils.dip2px(mCurActivity, 270),
				android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
		params_first.setMargins(SystemUtils.dip2px(mCurActivity, 10), 0,
				SystemUtils.dip2px(mCurActivity, 10), 0);
		params = new android.widget.LinearLayout.LayoutParams(
				SystemUtils.dip2px(mCurActivity, 270),
				android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
		params.setMargins(0, 0, SystemUtils.dip2px(mCurActivity, 10), 0);
		// 圆角参数
		options = new DisplayImageOptions.Builder()
				.displayer(
						new RoundedBitmapDisplayer(SystemUtils.dip2px(
								mCurActivity, 5))).build();

		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
		}
		// 图标
		icon_anquan = (ImageView) mContentView.findViewById(R.id.icon2);
		icon_xinshouhelp = (ImageView) mContentView.findViewById(R.id.icon3);
		icon_happyshop = (ImageView) mContentView.findViewById(R.id.iv_left);
		// othetlist
		mListView = (ListView) mContentView.findViewById(R.id.mListView);
		mListView.setFocusable(false);
		mListView.setDividerHeight(0);
		findOtherListAdapter = new FindOtherListAdapter(mCurActivity, otherList);
		mListView.setAdapter(findOtherListAdapter);

		// 拨打客服电话
		call_toService = mContentView.findViewById(R.id.call_toService);
		// 风险评估
		toTiskTest = mContentView.findViewById(R.id.toTiskTest);
		iv_riskTest = (ImageView) mContentView.findViewById(R.id.iv_riskTest);
		tv_title_asses = (TextView) mContentView
				.findViewById(R.id.tv_title_asses);
		tv_desc_asses = (TextView) mContentView
				.findViewById(R.id.tv_desc_asses);
	}

	private void setListener() {

		call_toService.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				showDialog("客服电话：4000-137-000");
			}
		});

		linear_anquan.setOnClickListener(this);
		linear_help.setOnClickListener(this);
		rel_toShop.setOnClickListener(this);
		toTiskTest.setOnClickListener(this);

		find_sl.setScrollStateProvider(new ScrollStateProvider() {

			@Override
			public boolean canPullUp() {
				return false;
			}

			@Override
			public boolean canPullDown() {

				int scrollY = mScrollView.getScrollY();
				if (scrollY == 0 && KKDHorizontalScrollView.FLAG_CANPULLDOWN) {
					return true;
				}
				return false;
			}
		});
		find_sl.setOnPullListener(new OnPullListener() {

			@Override
			public void onPullUp(float pull) {

			}

			@Override
			public void onPullStateChange(byte state) {
				switch (state) {
				case ScrollerLayout.STATUS_IDLE:// 空闲状态
					mHeaderView.setVisibility(View.GONE);
					break;
				case ScrollerLayout.STATUS_PULL_DOWN:// 下拉：不满足hold条件
					mHeaderView.setVisibility(View.VISIBLE);
					mHeaderView.setState(XListViewHeader.STATE_NORMAL);
					break;
				case ScrollerLayout.STATUS_PULL_UP:// 上拉：不满足hold条件
					break;
				case ScrollerLayout.STATUS_UP_HOLD:// 上拉后等待状态
					break;
				case ScrollerLayout.STATUS_DOWN_HOLD:// 下拉后等待状态
					mHandler.post(new Runnable() {

						@Override
						public void run() {
							if (AppUtil.isConnect(mCurActivity)) {
								requestFindData();
							} else {
								AppUtil.makeToastForCustomer(mCurActivity,
										"网络连接失败！");
								Time_Date time_Date = new Time_Date();
								String time = time_Date.get_Year_Day();
								mHeaderView
										.setState(XListViewHeader.STATE_NORMAL);
								mHeaderView.setVisibility(View.GONE);
								find_sl.clearState();
							}
						}
					});
					mHeaderView.setState(XListViewHeader.STATE_REFRESHING);
					break;
				case ScrollerLayout.STATUS_ANIMATING:// 回弹动画状态
					break;
				case ScrollerLayout.STATUS_PULL_DOWN_ENABLE:// 下拉：满足hold条件，松开将hold
					mHeaderView.setState(XListViewHeader.STATE_READY);
					break;
				case ScrollerLayout.STATUS_PULL_UP_ENABLE: // 上拉：满足hold条件，松开将hold
					break;
				default:
					break;
				}
			}

			@Override
			public void onPullDown(float pull) {

			}
		});
	}

	// private void initHScroll() {
	// horizontalScrollView_find.scrollTo(0, 0);
	// linear_scroll.removeAllViews();
	// for (int i = 0; i < list_active.size(); i++) {
	// CircleImageView imageView = new CircleImageView(mCurActivity);
	// imageView.setFourRoundTrue();
	// imageView.setCircleRadiu(SystemUtils.dip2px(mCurActivity, 6));
	// if (i == 0) {
	// imageView.setLayoutParams(params_first);
	// } else {
	// imageView.setLayoutParams(params);
	// }
	// imageView.setScaleType(ImageView.ScaleType.FIT_XY);
	// ImageLoader.getInstance().displayImage(
	// list_active.get(i).getImage(), imageView,
	// R.drawable.home_ad);
	// final int flag_i = i;
	// imageView.setOnClickListener(new OnSingleClickListener() {
	//
	// @Override
	// public void onSingleClick(View v) {
	// SystemUtils.onEvent("Discovery_Banner_" + (flag_i + 1), 1);
	// Intent intent = new Intent(mCurActivity,
	// KKDWebActivity.class);
	// intent.putExtra("titleName", list_active.get(flag_i)
	// .getTitle());
	// intent.putExtra("useActiveTitle", true);
	// intent.putExtra("desc", list_active.get(flag_i).getDesc());
	// intent.putExtra("shareUrl", list_active.get(flag_i)
	// .getShareUrl());
	// LogUtil.e("shareUrl", list_active.get(flag_i).getShareUrl());
	// intent.putExtra("url", list_active.get(flag_i).getUrl());
	// if (list_active.get(flag_i).getUrl().indexOf("isPost") >= 0) {
	// intent.putExtra("isPost", "yes");
	// }
	// if (list_active.get(flag_i).getUrl().indexOf("isLogin") >= 0) {
	// intent.putExtra("isLogin", "yes");
	// }
	// mCurActivity.startActivity(intent);
	// }
	// });
	// linear_scroll.addView(imageView);
	// }
	// }

	@Override
	public void onResume() {
		super.onResume();
		requestFindData();
	}

	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		// mCycleBannerView.recycle();
		if (dialog_service != null) {
			dialog_service.cancel();
			dialog_service = null;
		}
	}

	/*
	 * 请求发现接口
	 */
	private void requestFindData() {
		KkdHttpMagager.getInstance().requestFind(FindData.class,
				new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						data = (FindData) responseBody;

						Message msg = Message.obtain();
						msg.what = SUCCESS_REQUEST;
						msg.obj = data;
						mHandler.sendMessage(msg);
						mHandler.sendEmptyMessage(END_REFRESH);
					}

					@Override
					public void onFailure(int statusCode, String desc) {
						Message msg = Message.obtain();
						msg.what = FAIL_REQUEST;
						msg.obj = desc;
						mHandler.sendMessage(msg);
						mHandler.sendEmptyMessage(END_REFRESH);
					}
				});
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.linear_anquan:
			if (!TextUtils.isEmpty(securityUrl)) {
				SystemUtils.onEvent("Discovery_SeCurity", 1);
				intent = new Intent(mCurActivity, KKDWebActivity.class);
				// intent.putExtra("url", com.kkd.kkdapp.Environment.getH5Url()
				// + "safety.html"); // 正式
				intent.putExtra("titleName", "安全保障");
				intent.putExtra("url", securityUrl);
				startActivity(intent);
			}
			break;
		case R.id.linear_help:
			SystemUtils.onEvent("Discovery_Q&A", 1);
			intent = new Intent(mCurActivity, KKDWebActivity.class);
			intent.putExtra("titleName", "新手指南");
			intent.putExtra("url", beginnerGuideUrl);
			startActivity(intent);
			break;
		case R.id.rel_toShop: // 快乐商城
			SystemUtils.onEvent("Discovery_HappyMarket", 1);
			intent = new Intent(mCurActivity, KKDWebActivity.class);
			intent.putExtra("url", happyShopUrl);
			intent.putExtra("coinMisUrl", coinMisUrl);
			startActivity(intent);
			if (data != null) {
				if (!TextUtils.isEmpty(data.getHappyShop()
						.getHappyShopNewImageUrl())) {
					PreferenceUtils.getInstance().setTimeStamp(mCurActivity,
							System.currentTimeMillis());
					happy_new.setVisibility(View.INVISIBLE);
				}
			}
			break;
		case R.id.toTiskTest: // 风险评估
			if (PreferenceUtils.getLogin(mCurActivity) != 0) {
				intent = new Intent(mCurActivity, LoginActivity.class);
				startActivity(intent);
			} else {

				if (CurUserModel.getMyInfo() != null
						&& CurUserModel.getMyInfo().isSurved != 0) {
					CurUserModel.getMyInfo().updateIsShowedAsses(0);
					showAssessmentDialog();
				} else {
					if (!TextUtils.isEmpty(assesUrl)) {
						intent = new Intent(mCurActivity, KKDWebActivity.class);
						intent.putExtra("url", assesUrl);
						startActivity(intent);
					}
				}
			}
			break;

		default:
			break;
		}
	}

	private Dialog mDialog;

	public void showAssessmentDialog() {
		if (mDialog != null) {
			mDialog.cancel();
			mDialog = null;
		}
		mDialog = DialogUtils.assessmentDialog(mCurActivity, "保守型",
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(mCurActivity,
								KKDWebActivity.class);
						intent.putExtra("url",
								CurUserModel.getMyInfo().survedUrl);
						startActivity(intent);
						mDialog.dismiss();
					}
				});
		mDialog.show();
	}

	public void ScrollToTop() {
		// find_sl.ScrollToTop();
		mScrollView.fullScroll(ScrollView.FOCUS_UP);
	}

	// /*
	// * 请求接口
	// */
	// private void requestDataFromWeb(String customerId) {
	// KkdHttpMagager.getInstance().requestFindMoreAct(customerId,
	// FindData.class, new HttpCallBack() {
	//
	// @Override
	// public void onSuccess(int statusCode, Object responseBody) {
	// FindData data = (FindData) responseBody;
	// if (data.getActivities() != null
	// && data.getActivities().size() > 0) {
	// PreferenceUtils.getInstance().updateFindActs(
	// mCurActivity, data.getActivities());
	// }
	// Message msg = Message.obtain();
	// msg.what = SUCCESS_REQUEST_COUNT;
	// msg.obj = data;
	// mHandler.sendMessage(msg);
	// }
	//
	// @Override
	// public void onFailure(int statusCode, String desc) {
	// }
	// });
	// }

	/**
	 * 加载缓存的banner
	 */
	private void loadBannerCache() {
		try {
			FindData findData = PreferenceUtils.getInstance().getFindData(
					mCurActivity);
			if (findData != null) {
				if (findData.getActivities() != null
						&& findData.getActivities().size() > 0) {
					Gson gson = new Gson();
					String json1 = gson.toJson(list_active);
					String json2 = gson.toJson(findData.getActivities());
					if (!json1.endsWith(json2)) {
						list_active.clear();
						list_active.addAll(findData.getActivities());
						// mCycleBannerView.notifyDataSetChanged();
						mCycleBannerView.update(list_active);
					}
					mCycleBannerView.setVisibility(View.VISIBLE);
					iv_default_banner.setVisibility(View.GONE);
				} else {
					mCycleBannerView.setVisibility(View.GONE);
					iv_default_banner.setVisibility(View.VISIBLE);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 拨打客服电话对话框
	 * 
	 * @param message
	 */
	private void showDialog(String message) {
		if (dialog_service != null) {
			dialog_service.cancel();
			dialog_service = null;
		}
		dialog_service = DialogUtils.callService(mCurActivity);
		dialog_service.show();
	}

}
